<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<!--页面的注释 -->
	<!--body有个onload事件,在dom树构建完毕后触发 -->
	<body onload="setInterval(getDataTime,1000);">
		<div id="enclock"></div>
		<div id="cnclock"></div>
	</body>
	<script>
		function getDataTime(){
			/*获取当前系统时间*/
			var date = new Date();
			
			/*获取页面上的div*/
			var enclock = document.getElementById("enclock");
			enclock.innerHTML = "<font color='red'>" + date+"</font>";
			
			var cnclock = document.getElementById('cnclock');
			
			var year = date.getFullYear();
			var month = date.getMonth()+1;/*月从0开始, 要+1*/
			var day = date.getDate();
			
			var hour = date.getHours();
			var minute = date.getMinutes();
			var second = date.getSeconds();/*获取当前秒数*/
			
			cnclock.innerText = year + "年" + month + "月" + day+ "日" + hour + "时" + minute + "分" + second + "秒";
		}
	</script>
</html>
